﻿using CTM.Web.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace CTM.Web.Models.Input
{
    public class Post
    {
        #region Properties

        [Key]
        public Guid Id { get; set; }

        [Required]
        [StringLength(100)]
        public string Title { get; set; }

        [Required]
        public string Description { get; set; }

        //[Required]
        public PostType? Type { get; set; }

        //[Required]
        public Emoticon? Emoticon { get; set; }

        public bool IsPrivate { get; set; }

        public bool IsDeleted { get; set; }

        public DateTime CreatedOn { get; set; }

        [StringLength(128)]
        public string CreatedBy { get; set; }

        public DateTime? ModifiedOn { get; set; }

        [StringLength(128)]
        public string ModifiedBy { get; set; }

        #endregion

        #region Relationship
        public virtual Category Category { get; set; }
        public virtual ICollection<Comment> Comments { get; set; }
        public virtual ICollection<Tag> Tags { get; set; }
        public virtual ApplicationUser Manager { get; set; }
        public virtual ApplicationUser Employee { get; set; }
        [InverseProperty("Post")]
        public virtual ICollection<Notification> Notifications { get; set; }
        #endregion

        public Post()
        {
            Type = PostType.Goals;
            Emoticon = CTM.Web.Utils.Emoticon.Neutral;
            IsPrivate = false;
            IsDeleted = false;
            CreatedOn = DateTime.UtcNow;
            //ModifiedOn = DateTime.UtcNow;
            Comments = new HashSet<Comment>();
            Tags = new HashSet<Tag>();
            Notifications = new HashSet<Notification>();
        }
    }
}